import { stringify } from 'querystring';
import request from '@/utils/request';
import { DEFAULT_URL_SHIFT_ARRANGE } from '@/constants';

export async function queryData(body) {
    return request(`${DEFAULT_URL_SHIFT_ARRANGE}/listAll`, { method: 'POST', body });
}

export async function saveData(body) {
    return request(`${DEFAULT_URL_SHIFT_ARRANGE}/insert`, { method: 'POST', body });
}

export async function updateData(body) {
    return request(`${DEFAULT_URL_SHIFT_ARRANGE}/update`, { method: 'POST', body });
}


export async function deleteData(option) {
    return request(`${DEFAULT_URL_SHIFT_ARRANGE}/remove`, option);
}

export async function downloadTemplate() {
    return request(`${DEFAULT_URL_SHIFT_ARRANGE}/deriveModel`);
}

export async function uploadData(params, option) {
    return request(`${DEFAULT_URL_SHIFT_ARRANGE}/uploadBatch?${stringify(params)}`, option);
}

export async function deriveExcel(option) {
    return request(`${DEFAULT_URL_SHIFT_ARRANGE}/deriveExcel`, option);
}

export async function deriveWord(option) {
    return request(`${DEFAULT_URL_SHIFT_ARRANGE}/deriveWord`, option);
}

export async function downloadWord({ type }, option) {
    return request(`${DEFAULT_URL_SHIFT_ARRANGE}/downloadWord1?type=${type}`, option);
}
